<?php  
if (!defined('BASEPATH')) exit('No direct script access allowed');

class Layout
{
    
    var $obj;
    var $layout;
    
    function Layout($layout = "")
    {
		$this->obj =& get_instance();
        $this->layout = $layout;
    }

    function setLayout($layout)
    {
      $this->layout = $layout;
    }
    
    function view($view, $data=null, $return=false)
    {
    	
		
			$data['content_for_layout'] = $this->obj->load->view($view,$data,true);
			
			if($return)
			{
				$output = $this->obj->load->view($this->layout,$data, true);
				return $output;
			}
			else
			{
				$this->obj->load->view($this->layout,$data, false);
			}
    }
	function view_json($is_ajax,$data=null,$return=false){
			$res="";
			$data['content_for_layout'] = $data["page"];
			
			if($return)
			{
				if($is_ajax){
				return json_encode($data);
				}
				else{
					$output = $this->obj->load->view($this->layout,$data, true);
					return $output;
				}
			}
			else
			{
				if($is_ajax){
					echo json_encode($data);
				}
				else{
					$this->obj->load->view($this->layout,$data, false);
				}
			}
	}
}
?>